package com.tc.gateway.device.remote;

import java.util.ArrayList;
import java.util.Collection;


import com.byq.mm.abstractx.cluster.server.executor.Executor;
import com.byq.mm.abstractx.device.Cluster;
import com.byq.mm.application.cluster.provider.OnoffProvider;
import com.byq.mm.application.cluster.server.OnoffServer;
import com.byq.mm.application.cluster.server.executor.OnoffExecutor;
import com.byq.mm.foundation.cluster.server.BasicClusterServer;
import com.tc.gateway.device.listener.OnoffListener;
import com.tc.gateway.device.type.OnoffDevice;

public class OnoffController extends RemoteController<OnoffDevice> implements OnoffListener{
	
	public OnoffController(OnoffDevice device) {
		super(device);

	}

	public void onChange(boolean value) {
		onoffserver.onChange(value);
		
	}
	OnoffServer onoffserver;
	public Executor getExecutor(BasicClusterServer server) {
		onoffserver = (OnoffServer)server;
		onoffserver.onChange(device.getOnOff());
		return new OnoffExecutor(){

			public void off() {
				// TODO Auto-generated method stub
				
			}

			public void on() {
				// TODO Auto-generated method stub
				
			}

			public void toggle() {
				device.toggle();
				
			}
		};
	}

	@Override
	protected Collection<Cluster> getSupportedClusters() {
		Collection<Cluster> rst = new ArrayList<Cluster>();
		Cluster c = new Cluster();
		c.setId(OnoffProvider.Define.CLUSTER_NAME);
		rst.add(c);
		return rst;
	}
}
